package org.atovio.coolexam.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.atovio.coolexam.entity.ExamPaperQuestion;

import java.util.List;

public interface ExamPaperQuestionMapper {

    @Insert("""
            insert into t_exam_paper_question (id, exam_paper_id, question_id)
            values (#{id}, #{examPaperId}, #{questionId})
            """)
    int insert(ExamPaperQuestion examPaperQuestion);

    @Select("""
            select * from t_exam_paper_question
            where exam_paper_id = #{examPaperId} and question_id = #{questionId}
            """)
    ExamPaperQuestion selectByExamPaperIdAndQuestionId(Integer examPaperId, Integer questionId);

    @Select("""
            select * from t_exam_paper_question
            where exam_paper_id = #{examPaperId}
            """)
    List<ExamPaperQuestion> selectByExamPaperId(Integer examPaperId);

    @Delete("""
            delete from t_exam_paper_question
            where exam_paper_id = #{examPaperId} and question_id = #{questionId}""")
    int deleteByExamPaperIdAndQuestionId(Integer examPaperId, Integer questionId);
}
